<template>
  <div class="main-content">
    <h3>部门列表</h3>
    <el-input
      placeholder="输入关键字进行过滤"
      v-model="filterText">
    </el-input>
    <div style="margin-top: 40px">
      <el-tree
        class="filter-tree"
        :data="dataExcel"
        :props="defaultProps"
        accordion
        :filter-node-method="filterNode"
        ref="tree">
      </el-tree>
    </div>
  </div>
</template>

<script>
  import teacher from "../../../../api/teacher";
  export default {
    name: "DeptList",
    watch: {
      filterText(val) {
        this.$refs.tree.filter(val);
      }
    },
    mounted() {
      this.downloads()
    },
    methods: {
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      downloads(){
        teacher.downloadExcel()
        .then(resp => {
          // console.log(resp.data)
          this.dataExcel = resp.data.excel
        })
      }
    },
    data() {
      return {
        filterText: '',
        dataExcel: [],
        defaultProps: {
          children: 'children',
          label: 'deptName'
        }
      };
    }
  }
  //TODO 中文关键词过滤
</script>

<style scoped>
  .main-content{
    padding: 0 36px;
  }
</style>
